//
//  ArticlesNews.m
//  BuffetNews
//
//  Created by weidawei on 14-11-2.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ArticlesNews.h"

@implementation ArticlesNews





- (id)ModelArticlesWithDictionary:(NSDictionary *)dicNews
{
    self = [super init];
    if (self) {

        self.dic = dicNews;
        self.pkArr = [NSMutableArray array];
        NSDictionary * data = [NSDictionary dictionary];
        data = [self.dic objectForKey:@"data"];
        NSDictionary * info = [data objectForKey:@"info"];
        self.next_url = [info objectForKey:@"next_url"];
        self.tuijian_list_url = [info objectForKey:@"tuijian_list_url"];
        NSDictionary * ipadconfig = [data objectForKey:@"ipadconfig"];
        NSMutableArray * pages = [ipadconfig objectForKey:@"pages"];
        NSMutableArray * diy = [NSMutableArray array];
        self.smallArr = [NSMutableArray array];
        for (NSDictionary * dic2 in pages) {
            [diy addObject:[dic2 objectForKey:@"diy"]];
            for (NSDictionary *dic3 in diy) {
                self.bgimage_url = [dic3 objectForKey:@"bgimage_url"];
            }
        }
        
        
        
      
        self.weburlArr = [NSMutableArray array];
        self.smallPkArr = [NSMutableArray array];
        self.pkArrBig = [NSMutableArray array];
        self.articles = [data objectForKey:@"articles"];

        
        self.tempArr = [NSMutableArray array];
        self.tempArr1 = [NSMutableArray array];
        
        NSDictionary *dicIpadconfig = [data objectForKey:@"ipadconfig"];
        NSMutableArray * arrPages = [NSMutableArray array];
        arrPages = [dicIpadconfig objectForKey:@"pages"];
        for (NSDictionary * temDic in arrPages) {
            self.stringTemp = [temDic objectForKey:@"articles"];
            self.tempArr = [NSMutableArray arrayWithArray:[self.stringTemp componentsSeparatedByString:@","]];

            [self.tempArr1 addObject:self.tempArr];
            [self.smallPkArr addObject:self.tempArr];
        }
        NSMutableArray * arr1 = [NSMutableArray array];
        NSMutableArray * arr2 = [NSMutableArray array];
        NSMutableArray * arr3 = [NSMutableArray array];
        NSMutableArray * arr4 = [NSMutableArray array];
        NSMutableArray * arr5 = [NSMutableArray array];
        NSMutableArray * arr6 = [NSMutableArray array];
        
        NSMutableArray * arr11 = [NSMutableArray array];
        NSMutableArray * arr22 = [NSMutableArray array];
        NSMutableArray * arr33 = [NSMutableArray array];
        NSMutableArray * arr44 = [NSMutableArray array];
        NSMutableArray * arr55 = [NSMutableArray array];
        NSMutableArray * arr66 = [NSMutableArray array];
        
        
        NSMutableArray * webarr1 = [NSMutableArray array];
        NSMutableArray * webarr2 = [NSMutableArray array];
        NSMutableArray * webarr3 = [NSMutableArray array];
        NSMutableArray * webarr4 = [NSMutableArray array];
        NSMutableArray * webarr5 = [NSMutableArray array];
        NSMutableArray * webarr6 = [NSMutableArray array];
        
        if (self.smallPkArr.count == 1) {
            arr1 = self.smallPkArr[0];
            
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr1) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr11 addObject:dic];
                        [webarr1 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            
            [self.pkArrBig addObject:arr11];
             [self.weburlArr addObject:webarr1];
            
        } else if (self.smallPkArr.count == 2) {
            arr1 = self.smallPkArr[0];
            arr2 = self.smallPkArr[1];
            
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr1) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr11 addObject:dic];
                        [webarr1 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr2) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr22 addObject:dic];
                        [webarr2 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            
            [self.pkArrBig addObject:arr11];
            [self.pkArrBig addObject:arr22];
            [self.weburlArr addObject:webarr1];
            [self.weburlArr addObject:webarr2];
            
            
        } else if (self.smallPkArr.count == 3) {
            arr1 = self.smallPkArr[0];
            arr2 = self.smallPkArr[1];
            arr3 = self.smallPkArr[2];
            
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr1) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr11 addObject:dic];
                        [webarr1 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr2) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr22 addObject:dic];
                        [webarr2 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr3) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr33 addObject:dic];
                        [webarr3 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            [self.pkArrBig addObject:arr11];
            [self.pkArrBig addObject:arr22];
            [self.pkArrBig addObject:arr33];
            [self.weburlArr addObject:webarr1];
            [self.weburlArr addObject:webarr2];
            [self.weburlArr addObject:webarr3];
            
        } else if (self.smallPkArr.count == 4) {
            arr1 = self.smallPkArr[0];
            arr2 = self.smallPkArr[1];
            arr3 = self.smallPkArr[2];
            arr4 = self.smallPkArr[3];
            
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr1) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr11 addObject:dic];
                        [webarr1 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr2) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr22 addObject:dic];
                        [webarr2 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr3) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr33 addObject:dic];
                        [webarr3 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr4) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr44 addObject:dic];
                        [webarr4 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }

            [self.pkArrBig addObject:arr11];
            [self.pkArrBig addObject:arr22];
            [self.pkArrBig addObject:arr33];
            [self.pkArrBig addObject:arr44];
            [self.weburlArr addObject:webarr1];
            [self.weburlArr addObject:webarr2];
            [self.weburlArr addObject:webarr3];
            [self.weburlArr addObject:webarr4];
            
            
        } else if (self.smallPkArr.count == 5) {
            arr1 = self.smallPkArr[0];
            arr2 = self.smallPkArr[1];
            arr3 = self.smallPkArr[2];
            arr4 = self.smallPkArr[3];
            arr5 = self.smallPkArr[4];
            
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr1) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr11 addObject:dic];
                        [webarr1 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr2) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr22 addObject:dic];
                        [webarr2 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr3) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr33 addObject:dic];
                        [webarr3 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr4) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr44 addObject:dic];
                        [webarr4 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            for (NSDictionary *dic in self.articles) {
                for (NSString * string in arr5) {
                    if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                        [arr55 addObject:dic];
                        [webarr5 addObject:[dic objectForKey:@"weburl"]];
                    }
                }
            }
            [self.pkArrBig addObject:arr11];
            [self.pkArrBig addObject:arr22];
            [self.pkArrBig addObject:arr33];
            [self.pkArrBig addObject:arr44];
            [self.pkArrBig addObject:arr55];
            
            [self.weburlArr addObject:webarr1];
            [self.weburlArr addObject:webarr2];
            [self.weburlArr addObject:webarr3];
            [self.weburlArr addObject:webarr4];
            [self.weburlArr addObject:webarr5];
   
        } else {
            arr1 = self.smallPkArr[0];
            arr2 = self.smallPkArr[1];
            arr3 = self.smallPkArr[2];
            arr4 = self.smallPkArr[3];
            arr5 = self.smallPkArr[4];
            arr6 = self.smallPkArr[5];

        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr1) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr11 addObject:dic];
                    [webarr1 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr2) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr22 addObject:dic];
                    [webarr2 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr3) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr33 addObject:dic];
                    [webarr3 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr4) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr44 addObject:dic];
                    [webarr4 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr5) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr55 addObject:dic];
                    [webarr5 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
        for (NSDictionary *dic in self.articles) {
            for (NSString * string in arr6) {
                if ([string isEqualToString:[dic objectForKey:@"pk"]]) {
                    [arr66 addObject:dic];
                    [webarr6 addObject:[dic objectForKey:@"weburl"]];
                }
            }
        }
            [self.pkArrBig addObject:arr11];
            [self.pkArrBig addObject:arr22];
            [self.pkArrBig addObject:arr33];
            [self.pkArrBig addObject:arr44];
            [self.pkArrBig addObject:arr55];
            [self.pkArrBig addObject:arr66];
            [self.weburlArr addObject:webarr1];
            [self.weburlArr addObject:webarr2];
            [self.weburlArr addObject:webarr3];
            [self.weburlArr addObject:webarr4];
            [self.weburlArr addObject:webarr5];
            [self.weburlArr addObject:webarr6];
        }
    }
    return self;
    
}



@end
